<?php
$this->Html->addCrumb('Image Gallery', '/image-gallery-admin');
$this->Html->addCrumb('Photos');
$this->Html->addCrumb('Edit');
$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){      
         $("#deleteBtn").click(function(event){
          if(!$("#deleteBtn").attr("data-delete-confirm")) {
          $("#deleteBtn").attr("data-delete-confirm","");
            $.TWS_Overlay("confirm", {title : "Delete confirmation", message : "Are you sure you want to delete this record?", buttons : {ok :{onclick : function () { $.TWS_Overlay("hide"); $("#deleteBtn").attr("data-delete-confirm",true).trigger("click");}}}});
            event.preventDefault();
          }
        });
     });
       ';
$this->Html->scriptEnd();

?>


<h1>Edit Photo</h1>
<p>
  <span class="bold">Category::</span> <?php echo $this->Html->link($groupInfo['Category']['name'], array('controller' => 'albums', 'action' => 'index', 'admin'=>true, $groupInfo['Category']['id']));?> &gt;&gt; <span class="bold">Album::</span> <?php echo $this->Html->link($groupInfo['Album']['name'], array('controller' => 'photos', 'action' => 'index', 'admin'=>true, $groupInfo['Album']['id']));?>
</p>
<?php echo '<div id="actionLink">'.$this->Html->link('Back to list of Photos',array('action'=>'index','admin'=>true, $albumId)).'</div>'; ?>
<?php echo $this->Session->flash();?>
<?php echo $this->element('errors', array('errors' => isset($errors)? $errors : null)); ?>
<?php

echo $this->TWSForm->create('Photo',  array(
    'inputDefaults' => array(
        'div' => array('class'=>'row')),
        'class'=>'inlineForm',
        'type'=>'file'));
$record = $this->request->data['Photo'];
echo $this->TWSForm->input('album_id', array('type'=>'hidden', 'name'=>'PhotoAlbumId', 'value'=>$albumId));
echo '<p>'.$this->Html->image($record['image_path'], array('alt' => $record['caption'], 'class'=>'photo')).'</p>';
echo $this->TWSForm->input('caption', array('rows'=>'5','cols'=>'60','name'=>'PhotoCaption'));
echo $this->TWSForm->submit('Update', array('id'=>'editBtn', 'name'=>'editBtn', 'class'=>'button', 'div'=>false));
echo $this->TWSForm->submit("Delete", array('id'=>'deleteBtn','name'=>'deleteBtn', 'class'=>'button', 'div'=>false));
echo $this->TWSForm->end();

?>